package com.rc.saas.tenant.service.task;

import com.rc.saas.tenant.mapper.task.PlatformTaskSettingMapper;
import com.rc.saas.tenant.model.task.PlatformTaskSetting;
import com.rc.saas.tenant.model.task.PlatformTaskSettingExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * Create by Yang on 2021/7/14
 */
@Service
public class PlatformTaskSettingServiceImpl implements PlatformTaskSettingService {

    @Autowired
    private PlatformTaskSettingMapper platformTaskSettingMapper;

    @Override
    public PlatformTaskSettingMapper getMapper() {
        return platformTaskSettingMapper;
    }


    @Override
    public PlatformTaskSetting selectByTaskType(String taskType) {
        PlatformTaskSettingExample example = new PlatformTaskSettingExample();
        example.createCriteria().andTaskTypeEqualTo(taskType).andStatusEqualTo("0");

        List<PlatformTaskSetting> platformTaskSettings = platformTaskSettingMapper.selectByExample(example);
        if (CollectionUtils.isEmpty(platformTaskSettings)) {
            return null;
        }

        return platformTaskSettings.get(0);
    }
}
